#ifndef _FVP_PLAT_DEBUG_H_
#define _FVP_PLAT_DEBUG_H_

#ifndef __ASSEMBLER__
#include <stdint.h>
#include <fences.h>

/**
 * USERSW
 * Eight white boxes show the state of the User DIP switches. 
 * These represent switch S6 on the VE hardware, USERSW[8:1],
 * which is mapped to bits [7:0] of the SYS_SW register at address 0x9C010004.
 *
 * BOOTSW
 * Eight white boxes show the state of the VE Boot DIP switches.
 * These represent switch S8 on the VE hardware, BOOTSEL[8:1], which is mapped to bits [15:8] of the SYS_SW register at address 0x9C010004.
 */
static inline void set_user_switch(uint8_t val)
{
    uintptr_t addr = (uintptr_t)0x9C010004UL; //[7:0]

    DMB();
    *(volatile uint8_t *)addr = val;
}

static inline uint8_t get_user_switch(void)
{
    uintptr_t addr = (uintptr_t)0x9C010004UL; //[7:0]
    uint8_t val;

    DMB();
    val = *(volatile uint8_t *)addr;

    return val;
}

static inline void set_s6led(uint8_t val)
{
    uintptr_t addr = (uintptr_t)0x9C010008UL; //[7:0]

    DMB();
    *(volatile uint8_t *)addr = val;
}

#endif /* __ASSEMBLER__ */
#endif /* _FVP_PLAT_DEBUG_H_ */
